/*
 * Copyright @ Timon Trinh
 * Website http://trinhquochungnotes.blogspot.com
 */
package com.timon.gpsfollow.com.timon.utils;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.StyleSpan;
import android.util.Base64;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.timon.gpsfollow.R;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

import static com.timon.gpsfollow.R.*;

/**
 * An assortment of UI helpers.
 */
public class UIUtils {
    /**
     * Time zone to use when formatting all session times. To always use the
     * phone local time, use {@link java.util.TimeZone#getDefault()}.
     */
    public static String PACKNAME = "com.affle.dettol";

    public static final TimeZone VN_TIME_ZONE = TimeZone
            .getTimeZone("GMT+7:00");

    private static final int SECOND_MILLIS = 1000;
    private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
    private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
    private static final int DAY_MILLIS = 24 * HOUR_MILLIS;

    public static final long TOAST_LONG = 3 * SECOND_MILLIS;
    public static final long TOAST_SHORT = SECOND_MILLIS;

    /**
     * Flags used with {@link android.text.format.DateUtils#formatDateRange}.
     */
    private static final int TIME_FLAGS = DateUtils.FORMAT_SHOW_TIME
            | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY;

    private static SimpleDateFormat shortDate = new SimpleDateFormat(
            "dd MMM yyyy");
    private static SimpleDateFormat shortDate1 = new SimpleDateFormat("dd MMMM");
    private static StyleSpan sBoldSpan = new StyleSpan(Typeface.BOLD);
    // get default type face from context/assets.
    private static Typeface tfhelveticaneue = null;
    private static Typeface tfhelveticaneuebold = null;
    private static Typeface tfhelveticaneuebolditalic = null;
    private static Typeface tfhelveticaneuecondensedblack = null;
    private static Typeface tfhelveticaneuecondensedbold = null;
    private static Typeface tfhelveticaneueitalic = null;
    private static Typeface tfhelveticaneuelight = null;
    private static Typeface tfhelveticaneuelightitalic = null;
    private static Typeface tfhelveticaneuemedium = null;
    private static Typeface tfhelveticaneueultralight = null;
    private static Typeface tfhelveticaneueultralightitalic = null;

    private static Typeface tfDefaultTypeFace = null;

    private static final long sAppLoadTime = System.currentTimeMillis();
    private static final boolean DEBUG = GKIMLog.DEBUG_ON;

    private static final CharSequence HASHTAG = "UIUtils";
    private static Context applicationContext = null;
    private static Toast mToast;
    private static TextView mMessage;

    public static String formatBlockTimeString(long blockStart, long blockEnd,
            Context context) {
        TimeZone.setDefault(VN_TIME_ZONE);

        // NOTE: There is an efficient version of formatDateRange in Eclair and
        // beyond that allows you to recycle a StringBuilder.
        return DateUtils.formatDateRange(context, blockStart, blockEnd,
                TIME_FLAGS);
    }

    public static boolean isSameDay(long time1, long time2) {
        TimeZone.setDefault(VN_TIME_ZONE);

        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        cal1.setTimeInMillis(time1);
        cal2.setTimeInMillis(time2);
        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.DAY_OF_YEAR) == cal2
                .get(Calendar.DAY_OF_YEAR);
    }

    public static String getTimeAgo(long time, Context ctx) {
        if (time < 1000000000000L) {
            // if timestamp given in seconds, convert to millis
            time *= 1000;
        }

        long now = getCurrentTime(ctx);
        if (time > now || time <= 0) {
            return null;
        }

        // localize
        final long diff = now - time;
        if (diff < MINUTE_MILLIS) {
            return "just now";
        } else if (diff < 2 * MINUTE_MILLIS) {
            return "a minute ago";
        } else if (diff < 50 * MINUTE_MILLIS) {
            return diff / MINUTE_MILLIS + " minutes ago";
        } else if (diff < 90 * MINUTE_MILLIS) {
            return "an hour ago";
        } else if (diff < 24 * HOUR_MILLIS) {
            return diff / HOUR_MILLIS + " hours ago";
        } else if (diff < 48 * HOUR_MILLIS) {
            return "yesterday";
        } else {
            return diff / DAY_MILLIS + " days ago";
        }
    }

    /**
     * Populate the given {@link android.widget.TextView} with the requested text, formatting
     * through {@link android.text.Html#fromHtml(String)} when applicable. Also sets
     * {@link android.widget.TextView#setMovementMethod} so inline links are handled.
     */
    public static void setTextMaybeHtml(TextView view, String text) {
        if (TextUtils.isEmpty(text)) {
            view.setText("");
            return;
        }
        if (text.contains("<") && text.contains(">")) {
            view.setText(Html.fromHtml(text));
            view.setMovementMethod(LinkMovementMethod.getInstance());
        } else {
            view.setText(text);
        }
    }

    /**
     * Given a snippet string with matching segments surrounded by curly braces,
     * turn those areas into bold spans, removing the curly braces.
     */
    public static Spannable buildStyledSnippet(String snippet) {
        final SpannableStringBuilder builder = new SpannableStringBuilder(
                snippet);

        // Walk through string, inserting bold snippet spans
        int startIndex = -1, endIndex = -1, delta = 0;
        while ((startIndex = snippet.indexOf('{', endIndex)) != -1) {
            endIndex = snippet.indexOf('}', startIndex);

            // Remove braces from both sides
            builder.delete(startIndex - delta, startIndex - delta + 1);
            builder.delete(endIndex - delta - 1, endIndex - delta);

            // Insert bold style
            builder.setSpan(sBoldSpan, startIndex - delta,
                    endIndex - delta - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            delta += 2;
        }

        return builder;
    }

    public static void loadToImageView(String url, ImageView imageView) {
        if (url != null && imageView != null) {
            // UrlImageViewHelper.setUrlDrawable(imageView, url, false, 1, 1);
        }
    }

    public static void loadToImageView(String url, ImageView imageView,
            int screenwidth) {
        if (url != null && imageView != null) {
            // UrlImageViewHelper.setUrlDrawable(imageView, url, true,
            // screenwidth, -1);
        }
    }

    // public static void loadToImageView(String url, ImageView imageView,
    // UrlImageViewCallback callback, String id) {
    // if (url != null && imageView != null) {
    // UrlImageViewHelper.setUrlDrawable(imageView, url, callback, false,
    // -1, -1);
    // }
    // }

    // public static void loadToCache(Context context, String url,
    // UrlImageViewCallback callback, String id) {
    // if (url != null && (url.length() > 0) && id != null
    // && (id.length() > 0) && callback != null) {
    // UrlImageViewHelper.loadUrlDrawableWithId(context, url, callback,
    // false, 1, 1, id);
    // }
    // }
    //
    // public static void loadToCache(Context context, String url,
    // UrlImageViewCallback callback, int scaleWidth, int scaleHeight,
    // String id) {
    // if (url != null && (url.length() > 0) && id != null
    // && (id.length() > 0) && callback != null) {
    // UrlImageViewHelper.loadUrlDrawableWithId(context, url, callback,
    // true, scaleWidth, scaleHeight, id);
    // }
    // }

    public static String getSessionHashtagsString(String hashtags) {
        if (!TextUtils.isEmpty(hashtags)) {
            if (!hashtags.startsWith("#")) {
                hashtags = "#" + hashtags;
            }

            if (hashtags.contains(HASHTAG)) {
                return hashtags;
            }
            return HASHTAG + " " + hashtags;
        } else {
            return (String) HASHTAG;
        }
    }

    /**
     * Calculate whether a color is light or dark, based on a commonly known
     * brightness formula.
     *
     * @see {@literal http://en.wikipedia.org/wiki/HSV_color_space%23Lightness}
     */
    public static boolean isColorDark(int color) {
        return ((30 * Color.red(color) + 59 * Color.green(color) + 11 * Color
                .blue(color)) / 100) <= BRIGHTNESS_THRESHOLD;
    }

    private static final int BRIGHTNESS_THRESHOLD = 130;

    public static void preferPackageForIntent(Context context, Intent intent,
            String packageName) {
        PackageManager pm = context.getPackageManager();
        for (ResolveInfo resolveInfo : pm.queryIntentActivities(intent, 0)) {
            if (resolveInfo.activityInfo.packageName.equals(packageName)) {
                intent.setPackage(packageName);
                break;
            }
        }
    }

    // Shows whether a notification was fired for a particular session time
    // block. In the
    // event that notification has not been fired yet, return false and set the
    // bit.
    public static boolean isNotificationFiredForBlock(Context context,
            String blockId) {
        SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(context);
        final String key = String.format("notification_fired_%s", blockId);
        boolean fired = sp.getBoolean(key, false);
        sp.edit().putBoolean(key, true).commit();
        return fired;
    }

    public static long getCurrentTime(final Context context) {
        // if (DEBUG) {
        // return context.getSharedPreferences("mock_data",
        // Context.MODE_PRIVATE).getLong("mock_current_time",
        // System.currentTimeMillis())
        // + System.currentTimeMillis() - sAppLoadTime;
        // } else {
        return System.currentTimeMillis();
        // }
    }

    public static void safeOpenLink(Context context, Intent linkIntent) {
        try {
            context.startActivity(linkIntent);
        } catch (ActivityNotFoundException e) {
            showToast(context, "Couldn't open link");
        }
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public static void setActivatedCompat(View view, boolean activated) {
        if (hasHoneycomb()) {
            view.setActivated(activated);
        }
    }

    public static boolean isGoogleTV(Context context) {
        return context.getPackageManager().hasSystemFeature(
                "com.google.android.tv");
    }

    public static boolean hasFroyo() {
        // Can use static final constants like FROYO, declared in later versions
        // of the OS since they are inlined at compile time. This is guaranteed
        // behavior.
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
    }

    public static boolean hasGingerbread() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
    }

    public static boolean hasHoneycomb() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
    }

    public static boolean hasHoneycombMR1() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1;
    }

    public static boolean hasICS() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
    }

    public static boolean hasJellyBean() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
    }

    public static void cancelToast(Context context) {
        if (mToast != null) {
            mToast.cancel();
        }
    }

    public static void showToast(Context context, int aligment, String message) {
        if (applicationContext == null && context != null) {
            applicationContext = context.getApplicationContext();
        }
        if (applicationContext == null) {
            return;
        }
        if (mToast == null) {
            LayoutInflater inflater = (LayoutInflater) applicationContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            if (inflater == null) {
                return;
            }
            ViewGroup vg = (ViewGroup) inflater.inflate(R.layout.toast, null);

            if (vg == null) {
                return;
            }
            if (mMessage == null) {
                mMessage = (TextView) vg.findViewById(id.toast_message);
            }
            mToast = new Toast(applicationContext);
            mToast.setView(vg);
        }
        mToast.setGravity(aligment, 0, 0);
        if (mMessage != null) {
            mMessage.setText(message);
        }
        mToast.show();
    }

    public static void showToast(Context context, String message) {
        showToast(context, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, message);
    }

    public static final int HELVETICANEUEBOLD = 1;
    public static final int HELVETICANEUEBOLDITALIC = 2;
    public static final int HELVETICANEUECONDENSEDBLACK = 3;
    public static final int HELVETICANEUECONDENSEDBOLD = 4;
    public static final int HELVETICANEUEITALIC = 5;
    public static final int HELVETICANEUELIGHT = 6;
    public static final int HELVETICANEUELIGHTITALIC = 7;
    public static final int HELVETICANEUEMEDIUM = 8;
    public static final int HELVETICANEUEULTRALIGHT = 9;
    public static final int HELVETICANEUEULTRALIGHTITALIC = 10;

    private static final String TAG = UIUtils.class.getSimpleName();

    public static Drawable buildGadientDrawableFromColor(int topColor,
            int bottomColor) {
        int[] colors = { topColor, bottomColor };
        GradientDrawable result = new GradientDrawable(
                GradientDrawable.Orientation.TOP_BOTTOM, colors);
        return result;
    }

    public static int getDeviceWidth() {
        if (applicationContext != null) {
            return applicationContext.getResources().getDisplayMetrics().widthPixels;
        }
        return 0;
    }

    public static Drawable getDrawableDensityScaled(Drawable drwSource,
            int dstWidth, int dstHeight) {
        if ((drwSource instanceof BitmapDrawable)) {
            BitmapDrawable src = (BitmapDrawable) drwSource;
            Bitmap bmp = Bitmap.createScaledBitmap(src.getBitmap(), dstWidth,
                    dstHeight, false);
            if (bmp != null) {
                return new BitmapDrawable(applicationContext.getResources(),
                        bmp);
            }
        }
        return drwSource;
    }

    /**
     * @return
     */
    public static boolean isLandscape(Context context) {
        return ((context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) ? true
                : false);
    }

    public static void hideKeyboardIfNeed(View view) {
        if (view == null) {
            return;
        }
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()) {
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }

    /**
     * @return the number of days in that month
     */
    public static int getMaxDaysofMonth() {

        Calendar today = Calendar.getInstance();
        return today.getActualMaximum(Calendar.DAY_OF_MONTH);

    }

    /**
     * @param sday
     *            30 Dec 2013
     * @return
     */

    /**
     * @param day : this is string day format MM/dd/yyyy
     * @return day: format : dd/MM/yyy
     */
    public static String setFormatDay(String sday) {
        if (sday == null || sday == "")
            return null;
        String[] arr = sday.split("/");
        if (arr.length < 2)
            return null;
        if (arr.length > 2) {
            return arr[1] + "/" + arr[0] + "/" + arr[2];
        } else {
            return arr[1] + "/" + arr[0];
        }
    }

    /**
     * @return current day of calendar in devices
     */
    public static int getCurrentDay() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.DATE);
    }

    /**
     * @return current day of calendar in devices
     */
    public static boolean toDayIsMonday() {
        Calendar today = Calendar.getInstance();
        int day = today.get(Calendar.DAY_OF_WEEK);
        return day == Calendar.MONDAY;
    }

    public static int getCurrentWeek() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.WEEK_OF_YEAR);
    }

    /**
     * @return current month of calendar in devices
     */
    public static int getCurrentMonth() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.MONTH) + 1;
    }

    /**
     * @return current year of calendar in devices
     */
    public static int getCurrentYear() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.YEAR);
    }

    public static int getWeekOfMonth() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.WEEK_OF_MONTH);
    }

    public static int getDayOfMonth() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.DAY_OF_MONTH);
    }

    public static int getHourOfDay() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.HOUR_OF_DAY);
    }

    public static int getMinsOfHour() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.MINUTE);
    }

    public static int getSecondOfMins() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.SECOND);
    }

    /**
     * @return get next month
     */
    public static int getNextMonth() {
        Calendar today = Calendar.getInstance();
        today.add(Calendar.MONTH, 1);
        return today.get(Calendar.MONTH) + 1;
    }

    public static String getHourMinute() {
        Calendar today = Calendar.getInstance();
        return today.get(Calendar.HOUR_OF_DAY) + "h"
                + today.get(Calendar.MINUTE);
    }

    /**
     * @return get next month
     */
    public static String getNextMonthName() {
        return new DateFormatSymbols().getMonths()[getNextMonth() - 1];
    }

    public static String getNameMonth(int month) {
        return new DateFormatSymbols().getMonths()[month - 1];
    }

    public static boolean isThisWeek(int week) {

        return week == getCurrentWeek() ? true : false;
    }

    public static boolean isNextWeek(int week) {
        return week == getCurrentWeek() + 1 ? true : false;
    }

    public static void getKeyhash(Activity mActivity) {
        PackageInfo info;
        try {
            info = mActivity.getPackageManager().getPackageInfo(
                    mActivity.getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md;
                md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String something = new String(Base64.encode(md.digest(), 0));
                // String something = new
                // String(Base64.encodeBytes(md.digest()));
                Log.e("hash key", something);
            }
        } catch (NameNotFoundException e1) {
            Log.e("name not found", e1.toString());
        } catch (NoSuchAlgorithmException e) {
            Log.e("no such an algorithm", e.toString());
        } catch (Exception e) {
            Log.e("exception", e.toString());
        }
    }

    public static String getFormatShortDate(String intdate) {
        Calendar cal1 = Calendar.getInstance();
        try {
            cal1.setTimeInMillis(Long.parseLong(intdate));
            String formattedDate = shortDate.format(cal1.getTime());
            return formattedDate;
        } catch (Exception e) {
            // TODO: handle exception
            return "";
        }
    }

    public static String getFormatDateActivities(String date) {
        if (date == null || date == "")
            return "";

        Calendar cal1 = Calendar.getInstance();
        Calendar calNow = Calendar.getInstance();
        cal1.setTimeInMillis(Long.parseLong(date));
        GKIMLog.l(
                1,
                "getFormatDateActivities:" + date + " "
                        + cal1.getTimeInMillis() + " "
                        + calNow.getTimeInMillis());

        int diffYear = calNow.get(Calendar.YEAR) - cal1.get(Calendar.YEAR);
        int diffMonth = diffYear * 12 + calNow.get(Calendar.MONTH)
                - cal1.get(Calendar.MONTH);
        // result in millis
        long diff = calNow.getTimeInMillis() - cal1.getTimeInMillis();
        long diffSeconds = (diff / 1000) % 60;
        long diffMinutes = diff / (60 * 1000);
        long diffHours = diff / (60 * 60 * 1000);
        int diffInDays = (int) (diff / (1000 * 60 * 60 * 24));
        int diffWeeks = (int) (diffInDays / 7);
        if (diffMinutes <= 1) {
            return "now";
        } else if (diffMinutes <= 1) {
            return diffMinutes + " min ago";
        } else if (diffMinutes < 59) {
            return diffMinutes + " mins ago";
        } else if (diffHours <= 1) {
            return diffHours + " hour ago";
        } else if (diffHours <= 23) {
            return diffHours + " hours ago";
        } else if (diffWeeks <= 1) {
            if (diffInDays <= 1) {
                return diffInDays + " day ago";
            } else {
                return diffInDays + " days ago";
            }
        } else if (diffWeeks < 4) {
            return diffWeeks + " weeks ago";
        } else {
            if (diffMonth <= 1) {
                return diffMonth + " month ago";
            } else {
                return diffMonth + " months ago";
            }
        }

    }

    public static String getFormatShortDate1(String intdate) {
        Calendar cal1 = Calendar.getInstance();
        try {
            cal1.setTimeInMillis(Long.parseLong(intdate));
            String formattedDate = shortDate1.format(cal1.getTime());
            return formattedDate;
        } catch (Exception e) {
            // TODO: handle exception
            return "";
        }
    }

    @SuppressLint("DefaultLocale")
    public static String capitalizeFirstLetter(String original) {
        String sResut = "";
        if (original == null || original.length() <= 0)
            return sResut;

        String[] arr = original.split(" ");
        for (String string : arr) {
            sResut += string.substring(0, 1).toUpperCase()
                    + string.substring(1) + " ";
        }
        return sResut;
    }

    @SuppressLint("SimpleDateFormat")
    public static long convertDateToMills(String someDate) {
        if (someDate == null || someDate == "")
            return 0;

        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        sdf.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
        Date date = null;
        try {
            date = sdf.parse(someDate);
            return date.getTime() / 1000;
        } catch (java.text.ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @SuppressLint("SimpleDateFormat")
    public static String convertMillsToDate(long millis) {
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        df.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
        String result = df.format(millis * 1000);
        return result;
    }

    public static long convertMillsGMT(String time) {
        GKIMLog.l(1, TAG + " convertMillsGMT:" + time);
        Calendar calNow = Calendar.getInstance();
        calNow.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
        calNow.setTimeInMillis(Long.parseLong(time));
        long newTime = calNow.getTimeInMillis();
        GKIMLog.l(1, TAG + " convertMillsGMT new time :" + newTime);
        return newTime;
    }
//
//	public static void slideintop(ViewGroup v, Context ctx) {
//		Animation anim = AnimationUtils.loadAnimation(ctx, R.anim.slide_in_top);
//		v.startAnimation(anim);
//	}
//
//	public static void slideoutbottom(ViewGroup v, Context ctx) {
//		Animation anim = AnimationUtils.loadAnimation(ctx,
//				R.anim.slide_out_bottom);
//		v.startAnimation(anim);
//	}
//
//	public static void slideinleft(ViewGroup v, Context ctx) {
//		Animation anim = AnimationUtils
//				.loadAnimation(ctx, R.anim.slide_in_left);
//		v.startAnimation(anim);
//	}
//
//	public static void slideinright(ViewGroup v, Context ctx) {
//		Animation anim = AnimationUtils.loadAnimation(ctx,
//				R.anim.slide_in_right);
//		v.startAnimation(anim);
//	}
//
//	public static void slideoutleft(ViewGroup v, Context ctx) {
//		Animation anim = AnimationUtils.loadAnimation(ctx,
//				R.anim.slide_out_left);
//		v.startAnimation(anim);
//	}
//
//	public static void slideoutright(ViewGroup v, Context ctx) {
//		Animation anim = AnimationUtils.loadAnimation(ctx,
//				R.anim.slide_out_right);
//		v.startAnimation(anim);
//	}
//
//	public static void alphaout(ViewGroup v, Context ctx) {
//		Animation anim = AnimationUtils.loadAnimation(ctx, R.anim.alpha_out);
//		v.startAnimation(anim);
//	}
}
